import * as BABYLON from "babylonjs";

import Base from "./Base";
import type { AbstractMesh, Nullable, IMouseEvent } from "babylonjs";



export default class Event {

    private base: Base;
    constructor() {
        this.base = Base.getInstance();



        this.base.scene.onPointerObservable.add((pointerInfo) => {
            switch (pointerInfo.type) {
                case BABYLON.PointerEventTypes.POINTERUP:
                    this.navigate(pointerInfo.pickInfo?.pickedMesh, pointerInfo.event)
                    break;
            }
        });


    }

    private navigate(station: Nullable<AbstractMesh> | undefined, event: IMouseEvent) {
        if (!station) return
        if (!station.name.startsWith("LM")) return

        // navigate to the dist station
        this.base.gui.createNavigateMenu(station, event)


    }


}